<?php

namespace App\Models\Log;

use App\Models\Def\MainGamePlat;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Notifications\Notifiable;
use App\Models\Inf\Player;


class PlayerTransfer extends Model
{
    use Notifiable;

    protected static function boot()
    {
        parent::boot();
    }

    public $table = 'log_player_transfer';

    const CREATED_AT = 'created_at';

    const UPDATED_AT = 'updated_at';

    const TRANSFER_TYPE_IN = 1;

    const TRANSFER_TYPE_OUT = 2;

    const TRANSFER_STATUS_SUCCESS = 1;
    const TRANSFER_STATUS_FAILED = 0;
    const TRANSFER_STATUS_UNKNOWN = -1;

    public $fillable = [
        'player_id',
        'transferid',
        'plattransferid',
        'money',
        'direction',
        'status'
    ];


    public static $rules = [];

    public function player()
    {
        return $this->belongsTo(Player::class, 'player_id');
    }

    public function plat()
    {
        return $this->belongsTo(MainGamePlat::class, 'main_game_plats_id');
    }

    public function getDirection()
    {
        switch ($this->direction) {
            case self::TRANSFER_TYPE_IN:
                return '转入';
            case self::TRANSFER_TYPE_OUT:
                return '转出';
        }
    }

    public function getStatus()
    {
        switch ($this->status) {
            case self::TRANSFER_STATUS_SUCCESS:
                return '成功';
            case self::TRANSFER_STATUS_FAILED:
                return '失败';
            case self::TRANSFER_STATUS_UNKNOWN:
                return '未知';
        }
    }

}
